<template>
  <div class="supportCenterVerifier">
    <c-title :hide="false" text="核销"></c-title>
    <div class="verifier">
      <div class="userBox">
        <div class="image" v-if="info.member">
          <img :src="info.member.avatar_image" alt="" />
        </div>
        <div class="name" v-if="info.member">{{ info.member.nickname }}</div>
      </div>
      <div class="title">提现金额</div>
      <div class="inputBox">
        <div class="txt">￥</div>
        <van-field v-model="value" placeholder="0.00" readonly />
      </div>
      <div class="btn" @click="actionTag" v-if="info.status == 0">确认核销</div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      value: "",
      info: []
    };
  },
  activated() {
    this.getData();
  },
  methods: {
    actionTag() {
      $http
        .post("plugin.support-center.frontend.withdraw.write-off-action", { withdraw_money: this.value, log_id: this.$route.query.log_id }, "加载中")
        .then(response => {
          if (response.result === 1) {
            this.$dialog.alert({ message: "核销成功" });
            this.getData();
          } else {
            this.$dialog.alert({ message: response.msg });
          }
        })
        .catch(error => {
          console.log(error);
        });
    },
    getData() {
      $http
        .post("plugin.support-center.frontend.withdraw.write-off-page", { log_id: this.$route.query.log_id}, "加载中")
        .then(response => {
          if (response.result === 1) {
            this.info = response.data;
            this.value = response.data.withdraw_money;
          } else {
            this.$dialog.alert({ message: response.msg });
          }
        })
        .catch(error => {
          console.log(error);
        });
    }
  }
};
</script>
<style lang="scss" scoped>
.verifier {
  margin: 0.75rem;
  border-radius: 0.63rem;
  background: #fff;
  box-sizing: border-box;
  padding-bottom: 0.97rem;

  .btn {
    width: 20rem;
    height: 2.5rem;
    background: #fe5e56;
    border-radius: 2.81rem;
    margin: 0 auto;
    font-size: 0.94rem;
    font-weight: 600;
    color: #fff;
    line-height: 2.5rem;
    margin-top: 1.41rem;
  }

  .inputBox {
    display: flex;
    align-items: center;
    overflow: hidden;

    .txt {
      font-size: 0.68rem;
      margin-left: 0.63rem;
      margin-top: 0.625rem;
    }

    .van-cell {
      padding: 10px 0.63rem;
      padding-left: 0;
      font-size: 1.75rem;
    }
  }

  .title {
    color: #2c2c2c;
    font-size: 0.75rem;
    text-align: left;
    margin-left: 0.63rem;
  }

  .userBox {
    margin: 0 0.63rem;
    height: 3.25rem;
    padding: 0.75rem 0;
    border-radius: 0.63rem;
    // border-bottom: 1px solid #ececec;
    display: flex;
    align-items: center;
    margin-bottom: 1.34rem;

    .name {
      font-size: 0.88rem;
    }

    .image {
      width: 1.75rem;
      height: 1.75rem;
      margin-right: 0.47rem;
      border-radius: 50%;

      img {
        width: 100%;
        height: 100%;
        border-radius: 50%;
      }
    }
  }
}
</style>
